<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>非受控组件</title>
  <!-- react核心库 -->
  <script src="../js/react.development.js"></script>
  <!-- react扩展库支持react操作DOM -->
  <script src="../js/react-dom.development.js"></script>
  <!-- 1.ES6转ES5；2.jsx转js -->
  <script src="../js/babel.min.js"></script>
  <!-- prop操作 -->
  <script src="../js/prop-types.js"></script>
  <style>
    p {
      text-align: center;
    }
  </style>
</head>

<body>
  <div id="test"></div>
  <script type="text/babel">
    class Login extends React.Component {
      handleSubmit = (event) => {
        event.preventDefault()
        alert('用户名：'+this.username.value+'，密码：'+this.password.value)
      }
      render() {
        return (
          <form action="http://baidu.com" onSubmit={this.handleSubmit}>
            <p>账户：<input type="text" ref={c=>this.username=c} placeholder='账户名' name='username' /></p>
            <p>密码：<input type="text" ref={c=>this.password=c} placeholder='密码' name='password' /></p>
            <p><button>登录</button></p>
          </form>
        )
      }
    }
    ReactDOM.render(<Login />, document.getElementById('test'))
  </script>
</body>

</html>